import { ref } from 'vue'
import { defineStore } from 'pinia';

// 存储当前会话信息的pinia仓库
export const ConversationStore = defineStore('conversationStore', () => {

    const conversationInfo = ref({
        id: null,
        name: null,
        avatar: null,
        conversationType: null,
        talkerId: null,
        createBy: null,
        createTime: null,
        lastMessageId: null,
        lastMessageContent: null,
        lastMessageTime: null,
        unreadMessageCount: null
    })

    // 设置conversation_Store.conversationInfo里面的各项属性为null
    const clear = () => {
        conversationInfo.value = {
            id: null,
            name: null,
            avatar: null,
            conversationType: null,
            talkerId: null,
            createBy: null,
            createTime: null,
            lastMessageId: null,
            lastMessageContent: null,
            lastMessageTime: null,
            unreadMessageCount: null
        }
    }


    //向外暴露的变量或方法
    return {
        conversationInfo,
        clear
    }
})